<?php

/**
 *      
 * 
 *  @author          Edmandie Samonte        (edmandie.samonte@gmail.com)
 *  @copyright       2011 
 * 
 */
class Dashboard extends CI_Controller{
    
    function index(){
        $this->load->library('session');
        $this->load->database();
        
        if($this->session->userdata('logged_in') !== 'true')
            header('Location: ' .base_url());
        $eID = $this->session->userdata('eID');
        $res = $this->db->get_where('employee',array('eID'=>$eID))->result();
        if(!isset($res[0])){
            $this->session->sess_destroy();
            header('Location: ' . site_url('error/cookie'));
        }
        
        $data['user'] = $res[0];
        
        $res = $this->db->get_where('positions',array('posID'=>$res[0]->ePosition))->result();
        $data['position'] = $res[0]->posName; 
        
        $data['employees'] = $this->db->get('employee')->result();
        $data['position_list'] = $this->db->get('positions')->result();
        $this->load->helper('HTML');
        $this->load->view('dashboard',$data);
    }
    function logout(){
        $this->load->library('session');
        $this->session->sess_destroy();
        header('Location: ' . base_url());
    }
}

?>
